package com.treasure.mall.biz.entity.product;

import com.treasure.mall.zbq.common.constant.Constant;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 *
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.biz.entity.merchant
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/6/11 09:28
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * Copyright 2019-2022 com.treasure.mall.biz.entity.merchant Inc. All rights reserved.
 */
@Entity
@Getter
@Setter
@Table(name = "zb_category")
@Cacheable(false)
public class CategoryPO {
    /**
     * catId
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "cat_id")
    private Long catId;

    /**
     * 分类名
     */
    @Column(name = "cat_name", length = 100)
    private String catName;

    /**
     * 父类id
     */
    @Column(name = "parent_cat_id")
    private Long parentCatId;

    /**
     * 排序号
     */
    @Column(name = "sort_no")
    private Integer sortNo;

    /**
     * 树路径
     */
    @Column(name = "tree_path", length = 500)
    private String treePath;

    /**
     * 深度
     */
    @Column(name = "depth")
    private Integer depth;

    /**
     * 创建时间
     */
    @Column(name = "create_time", columnDefinition = Constant.DATE_COLUMN_DEFINITION)
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @Column(name = "update_time", columnDefinition = Constant.DATE_COLUMN_DEFINITION)
    private LocalDateTime updateTime;

    /**
     * 佣金比例
     */
    @Column(name = "commission_rate", scale = 3, precision = 6)
    private BigDecimal commissionRate;

    /**
     * 一级返利比例
     */
    @Column(name = "rebate_rate_one", scale = 3, precision = 6)
    private BigDecimal rebateRateOne = BigDecimal.ZERO;

    /**
     * 二级返利比例
     */
    @Column(name = "rebate_rate_two", scale = 3, precision = 6)
    private BigDecimal rebateRateTwo = BigDecimal.ZERO;

    /**
     * 备注
     */
    @Column(name = "remark", length = 400)
    private String remark;

    /**
     * 分类图片
     */
    @Column(name = "cat_pic", length = 300)
    private String catPic;

    /**
     * 推荐标志
     */
    @Column(name = "recommend_flag")
    private Integer recommendFlag;

    /**
     * 状态
     */
    @Column(name = "statusCode")
    private Integer statusCode;


    public BigDecimal getCommissionRate() {
        if (this.commissionRate == null) {
            return BigDecimal.ZERO;
        }
        return commissionRate;
    }
}
